package com.shangbang.verb.service.impl.recruit;

import com.shangbang.verb.dao.recruit.NounMapper;
import com.shangbang.verb.entity.recruit.NounEntity;
import com.shangbang.verb.service.recruit.NounService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NounServiceImpl implements NounService {
    @Autowired
    private NounMapper nounMapper;
    @Override
    public Object createNoun(String userDefault, String workDefault, Integer uid) {
        NounEntity nounEntity = nounMapper.selectByUid(uid);
        if (nounEntity==null){
            nounEntity = new NounEntity();
            nounEntity.setUserDefault(userDefault);
            nounEntity.setWorkDefault(workDefault);
            nounEntity.setUid(uid);
            nounMapper.insert(nounEntity);
        }
        return nounEntity;
    }

    @Override
    public Object updateNoun(String userDefault, String workDefault, Integer nonid) {
        NounEntity nounEntity = nounMapper.selectById(nonid);
        if(nounEntity!=null){
            nounEntity.setUserDefault(userDefault);
            nounEntity.setWorkDefault(workDefault);
            nounMapper.updateById(nounEntity);
            return nounEntity;
        }

        return "";
    }

    @Override
    public Object getNoun(Integer uid) {
        NounEntity nounEntity = nounMapper.selectByUid(uid);
        if(nounEntity!=null){
            return nounEntity;

        }
        return "";
    }
}
